﻿using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Metadata.Entity
{
    /// <summary>
    /// 元数据帮助类
    /// </summary>
    public class MetaDataHelper
    {
        /// <summary>
        /// 获取数据类型
        /// </summary>
        /// <param name="dbType">数据库类型</param>
        /// <returns>数据类型</returns>
        public List<string> GetColumnDataType(string dbType)
        {
            List<string> dataTypes = new List<string>();

            switch (dbType.ToLower())
            {
                case "sqlserver":
                    dataTypes = new List<string>()
                    {
                        "int",
                        "tinyint",
                        "bigint",
                        "varchar",
                        "bit",
                        "char",
                        "date",
                        "datetime",
                        "datetime2",
                        "decimal",
                        "float",
                        "nchar",
                        "ntext",
                        "numeric",
                        "nvarchar",
                        "nvarchar(MAX)",
                        "text",
                        "varchar(MAX)"
                    };
                    break;
                case "mysql":
                    dataTypes = new List<string>()
                    {
                        "INTEGER",
                        "TINYINT",
                        "SMALLINT",
                        "BIGINT",
                        "DECIMAL",
                        "NUMERIC",
                        "BIT",
                        "FLOAT",
                        "DOUBLE",
                        "DATE",
                        "TIME",
                        "DATETIME",
                        //"TIMESTAMP",
                        "CHAR",
                        "VARCHAR",
                        //"BINARY",
                        //"VARBINARY",
                        //"BLOB",
                        "TEXT",
                        "ENUM",
                        "TINYTEXT",
                        "MEDIUMTEXT",
                        "LONGTEXT",
                    };
                    break;
                default:
                    break;
            }

            return dataTypes;
        }

        /// <summary>
        /// 获取逻辑视图对象属性的数据类型
        /// </summary>
        /// <returns>数据类型</returns>
        public List<string> GetAttributeDataType()
        {
            return new List<string>
            {
                "Binary","Bitmap","Boolean","Byte","Date","Time","Decimal","Float","Image","Integer","Money","Number","Serial","Text","Timestamp","Variable characters"
            };
        }                  
    }
}
